﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoredLis练习
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortedList = new SortedList();
            sortedList.Add(1, "徐汉权");
            sortedList.Add(2, "叶子荣");
            sortedList.Add(3, "陈泳洲");       
            Console.WriteLine("请输入你要查询的编号");
            int Id = int.Parse(Console.ReadLine());
            bool flag = sortedList.ContainsKey(Id);     
            if (flag)
            {
                string name =sortedList[Id].ToString(); 
                Console.WriteLine("你查找的患者姓名为：{0}",name);
            }
            else
            {
                Console.WriteLine("你查找的患者不存在，或者可能已经入土了");
            }
            Console.WriteLine("挂号编号信息如下");
            foreach (DictionaryEntry item in sortedList)
            {
                int key = (int)item.Key;    
                string value = (string)item.Value; 
                Console.WriteLine("编号为：{0}的患者名字为：{1}", key,value);
            }
            Console.ReadKey();
        }
    }
}
